<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<title>导入</title>
		<link rel="stylesheet" href="../css/common.css">
	    <link rel="stylesheet" href="../css/page.css">
	    <script src="../js/jquery-3.2.1.min.js"></script>
	    <script src="../js/media.js"></script>
	    <script src="../js/laydate/laydate.js"></script>
	    <style type="text/css">
    	body{
	    	background-color: rgb(248, 248, 248);
	    }
        .bd-0 {
            display: none;
        }
        .active {
            display: block;
        }
        .searchStart,.searchEnd{
        	margin-top: 0.1rem;
        	height: .44rem;
		    background: #fff;
		    overflow: hidden;
		    border-bottom: 1px solid #f2f2f2;
        }
        .searchLeft{
        	float: left;
		    width: 30%;
		    padding-left: .2rem;
		    line-height: .44rem;
        }
        .searchRight{ 
        	width:60%;
        	float: left;
           	height: .44rem;
		    line-height: .44rem;
		    text-align: right;
		    border: none;
		    outline: none;
	    }
	    .searchBtn{
	    	
	    	height: .44rem;
		    line-height: .44rem;
		    width: 40%;
		    text-align: center;
		    margin:0 auto;
		    margin-top: 0.1rem;
		    background:#37993e;
		    border-radius: 0.04rem;
		    color:#fff;
	    }
	    #pro_data{
	    	
	    }
	    #pro_data dt,#load_data dt{
	    	height: 0.36rem;
	    	padding: 0 0.16rem;
	    	background: none;
	    	font-size: 0.14rem;
	    	color: #666666;
	    	line-height: 0.36rem;
	    }
	    #pro_data dd{
	    	height: 0.44rem;
	    	border-bottom: 0.01rem solid #DCDCDC;
	    	padding: 0 0.16rem;
	    	background: #FFF;
	    }
	    #pro_data .list_left{
	    	height: 0.22rem;
	    	width: 1.1rem;
	    	border-right: 0.01rem solid #DCDCDC;
	    	font-size: 0.16rem;
	    	color: #333;
	    	margin-top: 0.11rem;
	    	margin-right: 0.08rem;
	    }
	    #pro_data input,#pro_data button,#pro_data p{
	    	float: left;
	    	
	    }
	    #pro_data input{
	    	border: none;
	    	line-height: 0.22rem;
	    	font-size: 0.16rem;
	    	margin-top: 0.11rem;
	    	outline: none;
	    	width: 2.0rem;
	    }
	    #pro_data button{
	    	color: #09af5b;
	    	font-size: 0.16rem;
	    	float: right;
	    }
	    #pro_data .unit{
	    	float: right;
	    	font-size: 0.16rem;
	    	color: #333;
	    	line-height: 0.44rem;
	    }
	    #load_data dd{
	    	height: 0.73rem;
	    	border-bottom: 0.01rem solid #DEDEDE;
	    	box-sizing: border-box;
	    	padding: 0.16rem;
	    	background: #FFF;	
	    }
	    #load_data dd .pro_name{
	    	font-size: 0.16rem;
	    	color: #333;
	    	
	    }
	    #load_data dd .pro_footer span{
	    	float: left;
	    	font-size: 0.14rem;
	    	color: #FF6701;
	    }
	    #load_data dd .pro_footer .load_time{
	    	float: right;
	    	color: #999999;
	    }
	    .pro_footer{
	    	margin-top: 0.1rem;
	    }
	    .sub_button{
	    	width:2.75rem;
	    	height: 0.44rem;
	    	background: #09AF5B;
	    	color: #FFF;
	    	line-height: 0.44rem;
	    	font-size: 0.14rem;
	    	margin: 0.16rem auto 0;
	    	text-align: center;
	    	border-radius: 0.08rem;
	    }
	    .load_btn{
    	    height: .44rem;
		    line-height: .44rem;
		    width: 40%;
		    text-align: center;
		    margin: 0.1rem auto;
		    background: #09AF5B;
		    border-radius: 0.04rem;
		    color: #fff;
	    }
	    .sel_btn,.sel_right{
	    	float: left;
	    }
	    .sel_right{
	    	width: 3.1rem;
	    }
	    .sel_btn{
	    	width: 0.25rem;
	    	height: 0.25rem;
	    	background: url(../img/load_sel.png) no-repeat center center;
	    	background-size: 0.24rem 0.24rem;
	    	margin-top: 0.125rem;
	    	margin-right: 0.07rem;
	    }
	    .seled{
	    	background:url(../img/load_seled.png) no-repeat center center;
	    	background-size: 0.24rem 0.24rem;
	    	
	    }
	    .finishbtn{
	    	display:none;
		    width: 2.75rem;
		    height: 0.44rem;
		    background: #09AF5B;
		    color: #FFF;
		    line-height: 0.44rem;
		    font-size: 0.14rem;
		    margin: 0.16rem auto 0;
		    text-align: center;
		    border-radius: 0.08rem;
	    }
	    .nodata{
	    	display:none;
		    position: absolute;
		    width: 100%;
		    height: 100%;
		    display: flex;
		    justify-content: center;
		    align-items: center;
		    color: #ccc;
		    font-size: .24rem;
	    }
	    </style>
	</head>
	<body>
		<dl id="load_data" style="display:none">
    		<dt>紫陶汇</dt>
    		<div class="ddwrap">
	     		<dd class="clearfix ddlist" data-order = "0001" style="display:none">
	    			<div class="sel_btn"></div>
	    			<div class="sel_right">
	    				<p class="pro_name">西施大壶</p>
		    			<div class="clearfix pro_footer">
		    				<span>￥1000</span>
		    				<span class="load_time">2018-05-12</span>
		    			</div>
	    			</div>
	    		</dd> 			
    		</div>
    	</dl>
		<div class="nodata">暂无数据</div>
		<div class="finishbtn">导入</div>
	</body>
	<script type="text/javascript">
//		$.ajax({//发送数据，获取可以导入的数据
//          url: base_url + '',
//          data: {
//          	
//          },
//          success: function (data) {
//              console.log(data)
//              
//          },
//          error:function(data){
//              console.log(data)
//          }
//      })
		var arr = [];
		$('dd').click(function(){
			if($(this).children('.sel_btn').hasClass('seled')){
				$(this).children('.sel_btn').removeClass('seled');
				var index_of = arr.indexOf($(this).data('order'));
				if(index_of!=-1){
					arr.splice(index_of,1);
				}
				console.log(arr);
			}else{
				$(this).children('.sel_btn').addClass('seled');
				arr.push($(this).data('order'));
				console.log(arr);
			}
		});
		pageajax();
		function pageajax(){
			$.ajax({
	            url:  base_url + 'ZITAOHUI/userOrder/importList',
	            type:'POST',
	            headers:{
	            	'Accept': 'application/json',
	            	'Content-type': 'application/json'
	            },
	            data: JSON.stringify({
	            	'store_id':sessionStorage.getItem('s_id'),
	            	'is_import':'0',
	            }),
	            success: function (data) {
	            	$('.ddlist').not($('.ddlist').eq(0)).remove();
	            	if(data.extend.list.length!=0){
	            		$(".nodata").hide();
	            		$('#load_data, .finishbtn').show();
	                    $.each(data.extend.list,function(index,item){
	                    	var cloneList = $('.ddlist').eq(0).clone(true);
	                    	cloneList.attr('data-order',item.order_id)
	                    	cloneList.find('.pro_name').text(item.produce_describe);//商品名称
	                    	cloneList.find('.pro_price').text('￥'+item.produce_price);//商品价格
	                    	cloneList.find('.load_time').text(changeTime1(item.order_create_time,'date'));//商品时间
	                    	cloneList.appendTo($('.ddwrap')).show()
	                    });	                		
	            	}else{
	            		$('#load_data, .finishbtn').hide();
	            	}
	            },
	            error:function(data){
	                console.log(data)
	            }
	        });			
		};
        $('.finishbtn').click(function(){
        	if(arr.length==0){
        		alert('请选择')
        		return 
        	};
        	$.ajax({
        		url:base_url + 'ZITAOHUI/userOrder/updateImportStatus',
        		type:"post",
	            headers:{
	            	'Accept': 'application/json',
	            	'Content-type': 'application/json'
	            },
        		data:JSON.stringify({
        			'order_id_array':arr.join(',')
        		}),
        		success:function(data){
        			console.log(data)
        			if(data.extend.status==1){
        				pageajax()
        				alert(data.msg)
        				window.location.href="./Shop-report.html?tabnum=3"
        			}
        		}
        	})
        })
	</script>
</html>
